package com.atguigu.cloud.controller;
import cn.hutool.core.util.IdUtil;
import com.atguigu.cloud.resp.ResultData;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;
@RestController
public class PayCircuitController {

    @GetMapping("/pay/circuit/{id}")
    public String myCircuit(@PathVariable("id") Integer id) {
        if (id < 0) {//报错
            throw new RuntimeException("Id不能为负数 ... ");
        }
        if (id == 9999) {//超时
            try {
                TimeUnit.SECONDS.sleep(5);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return "Hello" + id + IdUtil.simpleUUID();
    }
//
    @GetMapping("/pay/bulkhead/{id}")
    public String myBulkhead(@PathVariable("id") Integer id) {
        if (id < 0) {
            throw new RuntimeException("Id不能为负数 ... ");
        }
        if (id == 9999) {
            try {
                TimeUnit.SECONDS.sleep(5);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        return "Hello,bulkhead inputId: " + id+ "\t" + IdUtil.simpleUUID();
    }
//
//
    @GetMapping("/pay/ratelimit/{id}")
    public String myRatelimit(@PathVariable("id") Integer id) {
        return "Hello,欢迎来到inputId\t" + id +"\t"+ IdUtil.simpleUUID();
    }
}
